1
2
3
4 package joeq.ClassLib.sun15_linux.sun.misc;
5
6 import joeq.Memory.HeapAddress;
7
8 /***
9 * Unsafe
10 *
11 * @author John Whaley <jwhaley@alum.mit.edu>
12 * @version $Id: Unsafe.java 1479 2004-03-11 04:14:44Z jwhaley $
13 */
14 public final class Unsafe {
15
16 public boolean compareAndSwapLong(java.lang.Object o, long off, long a, long b) {
17 HeapAddress p = (HeapAddress) HeapAddress.addressOf(o).offset((int)off);
18
19 if (p.peek8() == a) {
20 p.poke8(b);
21 return true;
22 } else {
23 return false;
24 }
25 }
26
27 public boolean compareAndSwapInt(java.lang.Object o, long off, int a, int b) {
28 HeapAddress p = (HeapAddress) HeapAddress.addressOf(o).offset((int)off);
29
30 if (p.peek4() == a) {
31 p.poke4(b);
32 return true;
33 } else {
34 return false;
35 }
36 }
37
38 public boolean compareAndSwapObject(java.lang.Object o, long off, java.lang.Object a, java.lang.Object b) {
39 HeapAddress p = (HeapAddress) HeapAddress.addressOf(o).offset((int)off);
40
41 if (p.peek() == HeapAddress.addressOf(a)) {
42 p.poke(HeapAddress.addressOf(b));
43 return true;
44 } else {
45 return false;
46 }
47 }
48 }